<template>
<!--  身份审核页面-->
  <div id="top">
    <div>
      <el-card id="search">
        <el-input v-model="userInfo" placeholder="请输入公司名"></el-input>
        <el-button type="primary" plain @click="getactInfo()">查询</el-button>
          <el-button  type="danger" plain  @click="doshenhe()">审核</el-button>
        <el-button type="danger" plain @click="dontPass()">查看未通过</el-button>
      </el-card>
    </div>
    <el-row>
      <el-table :data="currentPageData" stripe style="width: 100%">
        <el-table-column prop="cname" label="公司名称" width="330"/>
        <el-table-column prop="cphone" label="联系电话" width="360"/>
        <el-table-column prop="caddress" label="公司地址" width="400"/>
        <el-table-column prop="createdate" label="创立时间" width="320"/>
        <el-table-column fixed="right" label="操作" width="230">
          <template  #default="scope">
            <el-button link type="primary" size="small"  @click="viewLook(scope.row)" v-show="bangzhu">
              查看详情
            </el-button>
            <el-button link type="primary" size="small" v-show="shenhe"  @click="viewPass(scope.row)">
              通过
            </el-button>
            <el-button link type="primary" size="small" v-show="shenhe" @click="viewDont(scope.row)">
              不通过
            </el-button>
            <div v-show="wtg">未通过</div>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <!--  分页组件-->
    <el-pagination
        v-model="currentPage"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="totalData.length"
        @current-change="handleCurrentChange">
    </el-pagination>
  </div>

  <!--  查看-->
  <el-dialog
      v-model="dialogVisible"
      title="报名用户"
      width="30%"
      :before-close="handleClose">
    <table>
      <tr>
        <td>公司介绍：</td>
        <td>{{users.cinto}}</td>
      </tr>
      <tr>
        <td>地址：</td>
        <td>{{users.caddress}}</td>
      </tr>
      <tr>
        <td>营业执照：</td>
        <td><img src="{{users.cimg}}"></td>
      </tr>
    </table>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible=false">取消</el-button>
        <el-button type="primary" @click="dialogVisible=false">确定</el-button>
      </span>
    </template>
  </el-dialog>


</template>

<script>

import doThis from "@/api/getData";

export default {
  name: "ReportList",
  data(){
    return{
      userList: [],
      userInfo:'',
      users:{},
      dialogVisible:false,
      shenhe:false,
      wtg:false,
      bangzhu: true,
      //  分页
      tableData: [], // 总数据
      totalData: [], // 总数据
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页显示的条数
    }
  },
  computed:{
    // 根据当前页面和每页显示的条数，计算分页后的数据
    currentPageData() {
      const { totalData, currentPage, pageSize } = this;
      const start = (currentPage - 1) * pageSize;
      const end = start + pageSize;
      return totalData.slice(start, end);
    },
  },
  mounted() {
    this.getUserList()
    // this.getUsers()
  },
  methods: {
    // 切换页码时的回调函数
    handleCurrentChange(page) {
      this.currentPage = page;
    },
    getUserList() {
      doThis.doGet("/company/list", {cstatus:2}).then(res => {
        console.log('全部公司======', res.data)
        this.tableData = res.data
        this.totalData = res.data
      })
    },
    //搜索
    getactInfo(){
      doThis.doGet("/company/list",{cname:this.userInfo,cstatus:2}).then(res =>{
        console.log("查询活动-------",res.data)
        // this.actList=res.data
        this.wtg=false
        this.shenhe=false
        this.bangzhu=true
        this.tableData = res.data
        this.totalData = res.data
      })
    },
    //审核页面
    doshenhe(){
      doThis.doGet("/company/list", {cstatus:1}).then(res => {
        console.log('全部公司======', res.data)
        this.wtg=false
        this.shenhe=true
        this.bangzhu=true
        this.tableData = res.data
        this.totalData = res.data
      })
    },
    //查看待审核的详情
    viewLook(row){
      this.users=row
      // this.getHelpList(row.aid)
      this.dialogVisible=true
    },
    //通过审核
    viewPass(row){
      if (confirm("确定要通过吗")){
        doThis.doGet("/company/update",{cid:row.cid,cstatus:2}).then(res =>{
          console.log("通过----",res.data)
          // this.tableData = res.data
          // this.totalData = res.data
          this.getUserList()
        })
      }
    },
    //不通过审核
    viewDont(row){
      if (confirm("确定要不通过吗")){
        doThis.doGet("/company/update",{cid:row.cid,cstatus:6}).then(res =>{
          console.log("不通过----",res.data)
          // this.tableData = res.data
          // this.totalData = res.data
          this.getUserList()
        })
      }
    },
    //查看未通过
    dontPass(){
      doThis.doGet("/company/list", {cstatus:6}).then(res => {
        console.log('全部公司======', res.data)
        this.wtg=true
        this.shenhe=false
        this.bangzhu = false
        this.tableData = res.data
        this.totalData = res.data
      })
    }
  }
}
</script>

<style scoped>
#top{
  margin-top: 47px;
  margin-left: -30px;
  background-color: #EBEBEB;
}

#search .el-input {
  width: 200px;
  margin-left: 30px;
  margin-right: 30px;
}

#search .el-button {
  margin-left: 30px;
  margin-right: 30px;
}
</style>